#include "guess.hpp"
#include <limits>
using namespace std;

int main(int argc, const char **argv)
{
    Item i;
    int num;
    do
    {
    loop:
        cout << "Guess Item's price: ";
        cin >> num;

        // 处理不合法输入
        if (cin.fail())
        {
            cin.clear();
            cin.ignore(numeric_limits<streamsize>::max(), '\n');
            cerr << "Illegal input!" << endl;
            goto loop;
        }

        if (num < 0 || num > 1000)
        {
            cerr << "Out of range!" << endl;
            goto loop;
        }
    } while (!i.comparePrice(num));
	system("pause");
    return 0;
}